package com.zu.commu.auto1_0.protocol.call;

import com.zu.commu.auto1_0.DataType1_0;
import com.zu.commu.auto1_0.protocol.CheckData;
import com.zu.commu.auto1_0.protocol.Util;
import com.zu.commu.exception.CommuException;

public class CallProtocol
{
  public byte[] remoteData(String meterNo)
    throws Exception
  {
    byte[] buf = new byte[14];
    buf[0] = 104;
    buf[1] = 8;
    buf[2] = 8;
    buf[3] = 104;
    try {
      Util u = new Util();
      byte[] b = u.hex2Byte(meterNo);
      for (int i = 0; i < b.length; i++)
        buf[(4 + i)] = b[i];
    }
    catch (Exception e)
    {
      throw new CommuException().setMessage("测控器地址号不合法！" + e.getMessage(), null);
    }
    buf[10] = 64;
    buf[11] = (byte)DataType1_0.REPORTDATA.toInt();
    buf[12] = new CheckData().getCrcCheck(buf, 4, 11);
    buf[13] = 22;
    return buf;
  }
}
